﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Elements {
  public class StaticHeader:StaticScreenPiece, IUIElement<StaticHeader> {
    public StaticHeader ( UIDocument doc , string name ) : base( doc , name ) {
    }
    public StaticHeader ( UIDocument doc ) : this( doc , "StaticHeader" ) {
    }

    #region IUIElement<StaticHeader> Members

    public void Validate ( StaticHeader val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        StaticHeader el = new StaticHeader( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( StaticHeader val ) {
      base.Copy( val );

      if( !string.IsNullOrEmpty( val.FrameTemplate ) )
        this.FrameTemplate = val.FrameTemplate;
      if( !string.IsNullOrEmpty( val.TextReference ) )
        this.TextReference = val.TextReference;
      if( val.TextColor != null )
        this.TextColor = val.TextColor;
    }

    #endregion

    public string FrameTemplate {
      get {
        return this.GetElement( "FrameTemplate" ).InnerText;
      }
      set {
        this.Validate( "FrameTemplate" , value );
      }
    }
    public string TextReference {
      get {
        return this.GetElement( "TextReference" ).InnerText;
      }
      set {
        this.Validate( "TextReference" , value );
      }
    }
    public new RGB TextColor {
      get {
        return (RGB)this.GetElement( "FrameTemplate" );
      }
      set {
        this.TextColor.Validate( value, "FrameTemplate" );
      }
    }

  }
}
